#!/usr/bin/env python3
# -*- coding=utf-8 -*-
# 题目1：有四个数字：1、2、3、4，能组成多少个互不相同且无重复数字的三位数？各是多少？
import itertools


def f1():
    count = 0
    for a in [1, 2, 3, 4]:
        for b in [1, 2, 3, 4]:
            for c in [1, 2, 3, 4]:
                if a != b and b != c and c != a:
                    count += 1
                    print(a, b, c)
    print("共有", count, "个互不相同且无重复数字的三位数")


def f2():
    count = 0  # 计数器，记录满足条件的个数

    for p in itertools.permutations([1, 2, 3, 4], 3):  # 从 1、2、3、4 中选取长度为 3 的排列
        count += 1  # 计数器加1
        print("".join(map(str, p)))  # 输出这个三位数
    print("共有", count, "个互不相同且无重复数字的三位数")


def f3():
    a = [1, 2, 3, 4]
    s = [(x, y, z)
         for x in a for y in a for z in a if x != y and y != z and z != x]
    for x in s:
        print(f"{x[0]}{x[1]}{x[2]}")
    print(f"共有{len(s)}个互不相同且无重复数字的三位数。")


f = f3
if __name__ == "__main__":
    f()
